package com.myrobot.ui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;
import javax.swing.JWindow;

class ToolsWindow extends JWindow
{
  private ScreenShotWindow parent;
  
  public ToolsWindow(ScreenShotWindow parent, int x, int y)
  {
    this.parent = parent;
    init();
    setLocation(x, y);
    pack();
    setVisible(true);
  }
  
  private void init()
  {
    setLayout(new BorderLayout());
    JToolBar toolBar = new JToolBar("Java 截图");
    

    JButton saveButton = new JButton(new ImageIcon("images/save.gif"));
    saveButton.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e) {
        try {
        	ToolsWindow.this.parent.saveImage();
        } catch (IOException e1) {
          e1.printStackTrace();
        }
      }
    });
    toolBar.add(saveButton);
    

    JButton closeButton = new JButton(new ImageIcon("images/close.gif"));
    closeButton.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e) {
        System.exit(0);
      }
    });
    toolBar.add(closeButton);
    
    add(toolBar, "North");
  }
}
